import 'package:lai_zhan/common/config/ExportConfig.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:lai_zhan/widget/CoachItem.dart';

class CoachListPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new _CoachListPageState();
  }
}

class _CoachListPageState extends State {
  RefreshController _controller;
  int itemcount = 10;

  LoadConfig _footerConfig = new LoadConfig(
      autoLoad: true, bottomWhenBuild: true, triggerDistance: 10.0);

  @override
  void initState() {
    // TODO: implement initState
    super.initState();

    _controller = new RefreshController();
  }

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new BaseScaffold(
      title: '私教课',
      titleColor: Color(AppColors.white),
      backgroundColor: Color(AppColors.primaryColor),
      back: () {
        NavigatorUtil.goBack(context);
      },
      body: new SmartRefresher(
          enablePullDown: false,
          enablePullUp: true,
          footerBuilder: _footerCreate,
          footerConfig: _footerConfig,
          controller: _controller,
          onRefresh: (up){
            new Future.delayed(new Duration(seconds: 3),(){
              setState(() {itemcount=15;});
              _controller.sendBack(false, RefreshStatus.idle);
            });
          },
          child: new ListView.builder(
            shrinkWrap: true,
            itemBuilder: (context, index){
              return new Column(children: <Widget>[
                new CoachItem(),
                new Container(height: 5,color: Color(AppColors.white),)],);
            },
            itemCount: itemcount,
          )),

//      body: new Column(
//        crossAxisAlignment: CrossAxisAlignment.start,
//        mainAxisSize: MainAxisSize.max,
//        children: <Widget>[
//          new Container(
//            margin: EdgeInsets.only(left: 15, top: 5, bottom: 5),
//            child: new Text(
//              '共60家',
//              style: AppConstant.middleText,
//            ),
//          ),
//          new Container(
//            height: 1,
//            color: Color(AppColors.grey800),
//          ),
//          new Padding(padding: EdgeInsets.all(3)),
////          new ListView.builder(
////            shrinkWrap:true,
////            itemBuilder: (context, index) {
////              return new Container(height: 10,color: Colors.red,);
////            },
////            itemCount: itemcount,
////          ),
//
//        ],
//      ),
    );
  }

  Widget _footerCreate(BuildContext context, int mode) {
    return new ClassicIndicator(
      mode: mode,
      refreshingText: '加载更多',
      idleIcon: const Icon(Icons.arrow_upward),
      idleText: '加载完成',
    );
  }
}
